<?php defined('SYSPATH') or die('no direct access allowed.');
//wybieranie odpowiednich kursow z bazy-lista	

    $db = new Database;
    $table = 'courses';
		
		if ($db->table_exists($table))
		{  
      $tab = $this->input->get(); //pobieranie z form
			$query = $db->select('distinct courses.*')->from($table)->where('Sem <='.$tab['select-semestr'])->get();
	    echo'<h3>Wybierz zaliczone kursy: </h3>';
      echo'<form action="result" method="get">';
      echo '<fieldset>';
      foreach ($query as $item)
			{
				echo'<p><input name="'.$item->Code.'" id="'.$item->Code.'" value="'.$tab['select-semestr'].$item->Code.'" type="checkbox" checked="checked"  class="checkbox" /><label for="'.$item->Code.'">'.$item->Name.'<br /><strong>'.$item->Code.'</strong></label></p>';
			}
			echo '</fieldset>';
			echo '<p class="buttons">
      <input type="reset" value="Wybierz wszystkie" class="button" />
			</p>';
      
      echo '<br /> Wybierz zaliczone kursy z przyszłych lat:<br /><br />';
      $query2 = $db->select('distinct courses.*')->from($table)->where('Sem >'.$tab['select-semestr'])->get();
      foreach ($query2 as $item)
			{
				echo'<p><input name="'.$item->Code.'" id="'.$item->Code.'" value="'.$tab['select-semestr'].$item->Code.'" type="checkbox" class="checkbox" /><label for="'.$item->Code.'">'.$item->Name.'<br /><strong>'.$item->Code.'</strong></label></p>';
			}
     
      echo '<br /><br />';
			echo	'<p class="buttons">
				<input type="submit" value="dalej" class="button important" /> 
        </p>';
			echo'</form>';
		}
		else
		{
			echo 'no! the '.$table.' table doesn\'t exist, so we can\'t continue =( ';
		}
		echo "<br/><br/>\n";
		echo 'done in {execution_time} seconds';
                                                 

?>
